<template>
  <div>
    <div class="back">
      <router-link to="/login">
        <img :src="backSrc" style="width: 40px; height: 40px" alt="" />
      </router-link>
      <div class="text">修改信息</div>
    </div>
    <div class="input">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="用户名称">
          <el-input v-model="form.nickname"></el-input>
        </el-form-item>
        <el-form-item label="个性签名">
          <el-input v-model="form.sign"></el-input>
        </el-form-item>
        <el-form-item label="目标成绩">
          <el-input v-model="form.score"></el-input>
        </el-form-item>
        <el-form-item class="sub">
          <el-button type="primary" @click="onSubmit">修改</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import axios from 'axios';
export default {
  data() {
    return {
      backSrc: require("../assets/images/back.png"),
      form: {
        username:"",
        nickname:"",
        sign:"",
        score:"",
      },
    };
  },
   methods: {
    //修改个人信息
      onSubmit() {
        this.form.username = this.$store.getters.getUser.name;

        console.log('submit!',this.form);
        axios.post("http://127.0.0.1/list/changemy",this.form,{
          headers: "application/x-www-form-urlencoded",
        }).then((res)=>{
          console.log(res);
          let {data} =res;
          console.log(data);
          if(data.code == 200){
            this.$router.push('/login');
          }
          else{
            alert("修改失败");
          }
        })
        .catch((err) => {
          console.log(err);
        });
      },
    },
};
</script>
<style lang="less" scoped>
.back {
  width: 100%;
  height: 60px;
  position: fixed;
  top: 0;
  right: 0;
  background: linear-gradient(to left, #29eac4, #4284db);
  img {
    position: absolute;
    left: 0;
    top: 10px;
  }
  .text {
    text-align: center;
    line-height: 60px;
    height: 60px;
    box-sizing: border-box;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
  }
}
.input{
  padding-top: 80px;
  width: 80%;
  margin: 0 auto;
}
</style>
<style lang="less">
.sub{
  margin-left: -60px !important;
}
</style>